package LeetCode.Map;

import java.util.ArrayList;

/**
 * @Author:galaxy_yan
 * @Date: 2022/11/16
 * @Time: 20:28
 * @Description
 */
public class firstUniqChar {
    public int firstUniqChar(String s) {
        int[] array=new int[26];
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            array[ch-'a']++;
        }
        for(int i=0;i<s.length();i++){
            char ch=s.charAt(i);
            if(array[ch-'a']==1){
                return i;
            }
        }
        return -1;
    }
}
